package com.hxzy.tms.action;

import java.util.List;

import com.hxzy.tms.entity.Project;
import com.hxzy.tms.entity.Task;
import com.hxzy.tms.entity.Team;
import com.hxzy.tms.service.ProjectService;
import com.hxzy.tms.service.ServiceResult;
import com.hxzy.tms.service.TaskService;
import com.hxzy.tms.service.TeamService;

public class ProjectAction extends AbstractAction {

	private static final long serialVersionUID = 5646348887040282015L;
	private ProjectService projectService;
	private TaskService taskService;
	private TeamService teamService;
	private Project project;
	private String projectKey=null;
	List<Task> list;
	
	public String projectTaskList(){
		this.list= taskService.read(project.getTeam().getId()).data;
		return INPUT;
	}
	
	public String projectPost() throws Exception {
		//list=taskService.read(project.getId()).data;
		if(isGET()){
			return INPUT;
		}
		
	/*	if(isGET()&&project.getId()!=null){
		List<Project> p=projectService.read(project.getId()).data;
		Project p2=p.get(0);
		this.project.setDesc(p2.getDesc());
		this.project.setTitle(p2.getTitle());
		return INPUT;	
		}*/
		ServiceResult<Project> result=null;
		if(project.getId()!=null){
			result=projectService.update(project.getId(), project.getTeam().getId(), project.getTitle(), project.getDesc());
		}else{
			result=projectService.create(project.getTeam().getId(), project.getTitle(),project.getDesc());
		}
		if(result.status==1){
		addActionError("保存成功");
			return SUCCESS;
		}else{
			addActionError(result.message);
			return ERROR;
		}
		
	}

	public String getProjectKey() {
		return projectKey;
	}


	public void setProjectKey(String projectKey) {
		this.projectKey = projectKey;
	}


	public TeamService getTeamService() {
		return teamService;
	}

	public void setTeamService(TeamService teamService) {
		this.teamService = teamService;
	}

	public TaskService getTaskService() {
		return taskService;
	}

	public void setTaskService(TaskService taskService) {
		this.taskService = taskService;
	}

	public List<Task> getList() {
		return list;
	}

	public void setList(List<Task> list) {
		this.list = list;
	}

	public ProjectService getProjectService() {
		return projectService;
	}

	public void setProjectService(ProjectService projectService) {
		this.projectService = projectService;
	}

	public Project getProject() {
		return project;
	}

	public void setProject(Project project) {
		this.project = project;
	}
	
	
}
